package com.example.exjnidemo.exbluetooth01;

import android.bluetooth.BluetoothDevice;
import android.content.Context;
import android.os.Build;
import android.util.Log;
import android.widget.Toast;

import com.google.gson.Gson;

import java.util.HashMap;

public class LogUtil {

    public static final String TAG = "[LOG_MSG]->";


    public static void v(String msg){
        Log.v(TAG,msg) ;
    }


    public static void t(Context context , String msg){
        Toast.makeText(context,msg,Toast.LENGTH_LONG).show();
    }



    /**
     * 打印找到的蓝牙设备
     *
     * @param device
     */
    public static void showFindBluetooth(BluetoothDevice device) {
        HashMap<String,Object> map= new HashMap<>() ;
        map.put("Name",device.getName());
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
            map.put("Type",device.getType());
        }
        map.put("Uuids",device.getUuids());
        map.put("BondState",device.getBondState());
        map.put("Address",device.getAddress());
        LogUtil.v("【showFindBluetooth】-> device = "+new Gson().toJson(map));
    }

}
